<template>
  <div class="container">
    <div class="nav-item" v-for="(item, index) in navsList" :key="index">
      <h3 class="custom-title">{{ item.nav_title }}</h3>
      <div class="modules">
        <router-link
          class="link-item"
          :to="{ path: itm.path, query: itm.query }"
          v-for="(itm, idx) in item.modules"
          :key="idx"
        >
          <!-- 以图片形式显示 -->
          <van-image
            class="module-icon"
            :src="itm.img_url"
            v-if="itm.img_url"
          />
          <!-- 以icon形式显示 -->
          <svg-icon class="custom-icon" v-else :icon-class="itm.icon_class" />
          <span class="module-name">{{ itm.module_name }}</span>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
import { navsList } from "./dictionary";
export default {
  name: "IndexView",
  data() {
    return {
      navsList,
    };
  },
};
</script>

<style>
.container {
  background-color: #f6f6f6;
  padding: 16px;
}
.container .nav-item {
  margin-bottom: 16px;
}
.container .nav-item:last-child {
  margin-bottom: 0px;
}
.modules {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.modules .link-item {
  width: 25%;
  margin: 8px 0px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}
.modules .link-item .module-icon {
  width: 45px;
  height: 45px;
}
.modules .link-item .module-name {
  color: #333;
  font-size: 13px;
  margin-top: 5px;
}
</style>
